public class Work3 {

    public static int fac(int n) {
        if (n == 1)
            return 1;
        else
            return n * fac(n - 1);
    }

    public static int facAdd(int n) {
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += fac(i);
        }
        return sum;
    }

    public static void main(String[] args) {
        //求1！+2！+3！+4！+........+n!的和
        int n = 5;
        System.out.println(facAdd(n));
    }
}
